<template>
	<view class="main">
		<view class="item">
			<image class="head-img" :src="userinfo.avatar" mode=""></image>
		</view>
		<view class="item">

			<view class="title">
				姓名：
			</view>
			<view class="value">
				{{userinfo.nickname}}
			</view>
		</view>
		<view class="item">

			<view class="title">
				类型：
			</view>
			<view class="value">
				<view class="" v-if="userinfo.level==1">
					总代理
				</view>
				<view class="" v-if="userinfo.level==2">
					教练
				</view>
				<view class="" v-if="userinfo.level==3">
					学员
				</view>
			</view>
		</view>
		<view class="item">

			<view class="title">
				手机号码：
			</view>
			<view class="value">
				{{userinfo.mobile}}
			</view>
		</view>
		<view class="item">

			<view class="title">
				简介：
			</view>
			<view class="value">
				{{userinfo.bio}}
			</view>
		</view>
		<view class="title" style="margin-top:20rpx;">
			驾照类型
		</view>
		<view class="type">
			<view class="item-type" :class="car_type ==0?'ed':''">
				<image v-if="car_type == 0" class="icon" src="../../static/cart1_ed.png" mode="widthFix"></image>
				<image v-else class="icon" src="../../static/cart1_not.png" mode="widthFix"></image>
				<view class="name">
					小车
				</view>
				<view class="name">
					C1/C2/C3
				</view>
				<image v-if="car_type == 0" class="selected" src="../../static/bg-selected.png" mode="widthFix"></image>
			</view>
			<view class="item-type" :class="car_type ==1?'ed':''">

				<image v-if="car_type == 1" class="icon" src="../../static/cart2_ed.png" mode="widthFix"></image>
				<image v-else class="icon" src="../../static/cart2_not.png" mode="widthFix"></image>
				<view class="name">
					货车
				</view>
				<view class="name">
					A2/B2
				</view>
				<image v-if="car_type == 1" class="selected" src="../../static/bg-selected.png" mode="widthFix"></image>
			</view>
			<view class="item-type" :class="car_type ==2?'ed':''">
				<image v-if="car_type == 2" class="icon" src="../../static/cart3_ed.png" mode="widthFix"></image>
				<image v-else class="icon" src="../../static/cart3_not.png" mode="widthFix"></image>

				<view class="name">
					客车
				</view>
				<view class="name">
					A1/A3/B1
				</view>
				<image v-if="car_type == 2" class="selected" src="../../static/bg-selected.png" mode="widthFix"></image>
			</view>
			<view class="item-type" :class="car_type ==3?'ed':''">
				<image v-if="car_type == 3" class="icon" src="../../static/cart4_ed.png" mode="widthFix"></image>
				<image v-else class="icon" src="../../static/cart4_not.png" mode="widthFix"></image>

				<view class="name">
					摩托车
				</view>
				<view class="name">
					D/E/F
				</view>
				<image v-if="car_type == 3" class="selected" src="../../static/bg-selected.png" mode="widthFix"></image>
			</view>
		</view>
		<u-button style="margin-top:50rpx" type="primary" @click="confirm">编辑</u-button>
	</view>
</template>

<script>
	import {
		userinfo
	} from "@/api/index.js"
	export default {
		data() {
			return {
				car_type: 0,
				userinfo: {
					nickname: "",
					avatar: "",
					bio: '',

				}
			};
		},
		mounted() {

		},
		onShow() {
			userinfo().then(res => {
				this.userinfo = res.data
				this.car_type = res.data.car_type
				uni.setStorageSync("userInfo", res.data)
			})
		},
		methods: {
			confirm() {
				uni.navigateTo({
					url: "/pages/user/editInfo"
				})
			}
		}
	}
</script>

<style lang="scss">
	.main {
		padding: 26rpx;

		.item {
			background-color: #fff;
			font-size: 28rpx;
			color: #656565;
			padding: 12rpx 26rpx;
			margin-bottom: 1px;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.head-img {
				border-radius: 100%;
				width: 100rpx;
				height: 100rpx;
				display: block;
				margin: 20rpx auto;
			}
		}
	}

	.type {
		display: flex;
		align-items: center;
		margin-top: 20rpx;
		justify-content: space-around;

		.item-type {
			width: 160rpx;
			height: 160rpx;
			text-align: center;
			cursor: pointer;
			border: 1px solid #ccc;
			color: #515151;
			border-radius: 10rpx;
			padding-top: 6rpx;
			position: relative;

			.selected {
				width: 40rpx;
				position: absolute;
				bottom: 0;
				right: 0;
			}
		}

		.ed {
			color: #1296db;
			border-color: #1296db;
		}

		.icon {
			width: 60rpx;
		}

		.name {
			font-size: 26rpx;

		}
	}
</style>